<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';

require_once './include/advisory_db.php';
//print_r($_SESSION);
$smarty->compile_check = true;

$smarty->display('header.tpl');

$smarty->assign('s',$_GET);
//jobupdate
$smarty->assign('state',$state);
$smarty->assign('chat_public',$chat_public);
$smarty->assign('rec_findchat',$rec_findchat);


$smarty->assign('colors',$colors);
$key = @array_search($_SESSION[usertype],$selectpages);

//print_r($findresume_orderby);
$where = "  WHERE 1=1 AND FIND_IN_SET('".$key."',`wb_selectpage`) AND `wb_status` = 1 ";
$order = " ORDER BY str_to_date(wb_date,'%m/%d/%Y') DESC";

if($_GET[action]=="search"){ 
    $arr = array();
	if($_GET[topic]!=''){ $arr[] = " (`wb_topic`  like '%".$_GET[topic]."%'  OR `wb_description` like '%".$_GET[topic]."%') ";}	
	if($_GET[host]!='') { $arr[] = " `wb_host` like '%".$_GET[host]."%'  ";}
    if($_GET['date']!='') { $arr[] = " `wb_date` = '".$_GET['date']."'  ";}

	if(!empty($arr)){
		$implode  = @implode("AND", $arr);
		$implode  = " AND ".$implode;
		$where    .= $implode;
	}
}

if($_GET[tp]==1){
	
	$by    = "wb_id"; 
	$order = "DESC" ;

	$_GET[order1]==''&&$order1=1;$_GET[order2]==''&&$order2=1;$_GET[order3]==''&&$order3=1;$_GET[order4]==''&&$order4=1;
	$_GET[order5]==''&&$order5=1;$_GET[order6]==''&&$order6=1;$_GET[order7]==''&&$order7=1;
	switch($_GET[swh]){
	   case 1:
		   $by = "str_to_date(wb_date,'%m/%d/%Y')";
		   if($_GET[order1]==1){$order_arr[1]=2; $order=" DESC ";$image_arr[1] = "<img src=\"images/dot1.gif\" align=\"absmiddle\">";}else{$order_arr[1]=1;$order=" ASC ";$image_arr[1] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	   case 2:
		   $by = "wb_topic";
		   if($_GET[order2]==1){$order_arr[2]=2; $order=" DESC ";$image_arr[2] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[2]=1;$order=" ASC ";$image_arr[2] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	   case 3:
			$by = "wb_host";
		   if($_GET[order3]==1){$order_arr[3]=2; $order=" DESC ";$image_arr[3] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[3]=1;$order=" ASC ";$image_arr[3] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	   case 4:
		   $by = "str_to_date(wb_starttime,'%h%i%p')";
		   if($_GET[order4]==1){$order_arr[4]=2; $order=" DESC ";$image_arr[4] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[4]=1;$order=" ASC ";$image_arr[4] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
		case 5:
		   $by = "str_to_date(wb_endtime,'%h%i%p')";
		   if($_GET[order5]==1){$order_arr[5]=2; $order=" DESC ";$image_arr[5] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[5]=1;$order=" ASC ";$image_arr[5] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	   case 6:
		   $by = "wb_timezone";
		   if($_GET[order6]==1){$order_arr[6]=2; $order=" DESC ";$image_arr[6] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[6]=1;$order=" ASC ";$image_arr[6] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	   case 7:
		   $by = "wb_color";
		   if($_GET[order7]==1){$order_arr[7]=2; $order=" DESC ";$image_arr[7] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[7]=1;$order=" ASC ";$image_arr[7] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	   case 8:
		   $by = "wb_updtime";
		   if($_GET[order8]==1){$order_arr[8]=2; $order=" DESC ";$image_arr[8] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[8]=1;$order=" ASC ";$image_arr[8] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
		   break;
	}
	$smarty->assign("order_arr",$order_arr);
	$smarty->assign("image_arr",$image_arr);
    $order = " ORDER BY $by $order ";

}

//echo "SELECT * FROM pa_webinar $where $order";
$nav = new buildNav;
$total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_webinar $where");
$nav->total_result = $total[count];
$nav->execute("SELECT * FROM pa_webinar $where $order");


$page = $nav->pagenav();
//echo $sql2;

$i=0;
while($list2 = $DB->fetch_array($nav->sql_result)){
   $datajob[$i]                   = $list2;
   $datajob[$i][wb_starttime]     = substr($list2[wb_starttime],0,2).":".substr($list2[wb_starttime],2,2).' '.substr($list2[wb_starttime],4,2);
   $datajob[$i][wb_endtime]     = substr($list2[wb_endtime],0,2).":".substr($list2[wb_endtime],2,2).' '.substr($list2[wb_endtime],4,2);
   $datajob[$i][wb_color]     =  $webinar_button_colors[$list2[wb_color]];
   $i++;
}
$smarty->assign("webinarlist",$datajob);
$smarty->assign("page",$page);
if($err!=''){
$smarty->assign("err",$err);
}
$smarty->assign("search",$reg_data);
$smarty->display('allleft.tpl');
$smarty->display('findwebinars.tpl');
$smarty->display('footer.tpl');
?>